<template>
    <z-page>
        <web-view class="h-full" :src="srcRef" @message="passMessageAction"> </web-view>
    </z-page>
</template>
<script lang="ts" setup>
import { ref, getCurrentInstance } from "vue";
import { router } from "@/helper";
import { safeEventChannelOnce } from "@/utils/eventChannel";
import { uniOnLoad } from "@/utils/lifeCycle";
const srcRef = ref("https://wangnangua.top/simple/ali/index.html");
// const srcRef = ref("http://172.20.0.120:5500/index.html");

const thisInstance = getCurrentInstance();
let thisEventChannel: any = null;
uniOnLoad({
    needLogin: false,
    cb() {
        thisEventChannel = safeEventChannelOnce(thisInstance, undefined);
    },
});

function passMessageAction(info: any) {
    let { detail } = info || {};
    let { data } = detail || {};
    let arr = Array.isArray(data) ? data : [];
    let authCode = arr[0];
    thisEventChannel?.emit("didGetAuth", {
        code: authCode,
    });
    router.navigateBack();
}
</script>
<style lang="scss" scoped></style>
